package net.dreamlu.util;

import java.util.Date;

/**
 * 时间处理工具类 写得比较屎
 * @author chunmeng.lu
 *
 */
public class TimeUtil {
	
	// 获取距离现在的时间 表示狠操蛋 
	public static String getGoTime(Date date){
		long timeMillis = System.currentTimeMillis() - date.getTime();
		StringBuilder timeGo = new StringBuilder();
		if(timeMillis / 1000 < 60){
			timeGo.append(timeMillis / 1000 + "秒前");	
		}else if(timeMillis / 1000 / 60 >= 1 && timeMillis / 1000 / 60 < 60){
			timeGo.append(timeMillis / 1000 / 60 + "分钟前");
		}else if(timeMillis / 1000 / 60 / 60 >= 1 && timeMillis / 1000 / 60 / 60 < 24){
			timeGo.append(timeMillis  / 1000 / 60 / 60 + "小时前");
		}else if(timeMillis  / 1000 / 60 / 60 / 24  >= 1 && timeMillis  / 1000 / 60 / 60 / 24 < 30 ){
			timeGo.append(timeMillis  / 1000 / 60 / 60 / 24  + "天前");
		}else if(timeMillis  / 1000 / 60 / 60 / 24 / 12 >= 1 && timeMillis  / 1000 / 60 / 60 / 24 / 12 < 12 ){
			timeGo.append(timeMillis  / 1000 / 60 / 60 / 24 / 12 + "月前");
		}else {
			timeGo.append(timeMillis  / 1000 / 60 / 60 / 24 / 12 / 356 + "年前");
		}
		return timeGo.toString();
	}
}
